//
//  AppDelegate.m
//  YiXiProject
//
//  Created by iMac on 2019/7/12.
//  Copyright © 2019 iMac. All rights reserved.
//

#import "AppDelegate.h"

#import "HomeMarryViewController.h"      /** app启动显示的第一个控制器头文件 */
#import "LoginViewController.h"

@interface AppDelegate ()

@end

@implementation AppDelegate


- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    // Override point for customization after application launch.
    
    NSLog(@"%@--%@--%@--%@",[YXUserdefaults GetDefaults:@"isLogin"],[YXUserdefaults GetDefaults:@"email"],[YXUserdefaults GetDefaults:@"password"],[YXUserdefaults GetDefaults:@"token"]);
    
    // 初始化window主窗口
    self.window = [[UIWindow alloc]initWithFrame:[UIScreen mainScreen].bounds];
    self.window.backgroundColor = [UIColor whiteColor];
    
    // 显示当前主窗口
    [self.window makeKeyAndVisible];
    
    // 初始化页面出现时显示的页面 (首页)
    HomeMarryViewController *homeVC = [[HomeMarryViewController alloc]init];

    // 给页面加导航条
    UINavigationController *nav = [[UINavigationController alloc]initWithRootViewController:homeVC];
    
    // 初始化页面出现时显示的页面(登陆)
    LoginViewController *logVC = [[LoginViewController alloc]init];
    
    // 给页面加导航条
    UINavigationController *navLog = [[UINavigationController alloc]initWithRootViewController:logVC];
        
    // 最后设置程序启动成功后显示的根视图页面
    if([[YXUserdefaults GetDefaults:@"isLogin"] isEqualToString:@"NO"] || [YXUserdefaults GetDefaults:@"isLogin"] == nil || [[YXUserdefaults GetDefaults:@"isLogin"] isEqual:[NSNull null]])
    {
        self.window.rootViewController = navLog;
    }
    else
    {
        self.window.rootViewController = nav;
    }
    
    
    
    
    return YES;
}


- (void)applicationWillResignActive:(UIApplication *)application {
    // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
    // Use this method to pause ongoing tasks, disable timers, and invalidate graphics rendering callbacks. Games should use this method to pause the game.
}


- (void)applicationDidEnterBackground:(UIApplication *)application {
    // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
    // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
}


- (void)applicationWillEnterForeground:(UIApplication *)application {
    // Called as part of the transition from the background to the active state; here you can undo many of the changes made on entering the background.
}


- (void)applicationDidBecomeActive:(UIApplication *)application {
    // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
}


- (void)applicationWillTerminate:(UIApplication *)application {
    // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
}


@end
